home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / comms / other / recentscript / importers / miamionlinesearch.rexx
OS/2 REXX Batch file  |  1999-05-17  |  3KB  |  110 lines

  1. /*****
  2.     $VER: MiamiOnlineSearch.rexx 1.0 (18.04.99)
  3.   RecentScript Online Search Importer ©Arndt van der Molen
  4.     Miami online support by Detlef Wojtaszkiewicz
  5.  
  6.   RecentScript Importer for online searching the AmiNet
  7.  
  8.   is a MUIRexx subapplication and can not be started directly.
  9.  
  10.   It is called only from RecentScript at the 'Import' button.
  11.  
  12.   This importer delivers the filename of a temporary file with
  13.   a maximum of 400 archives matching the search string. The search
  14.   string must be entered in the RecentScript GUI in the string gadget.
  15.  
  16.   Thanks:
  17.     Thanks to 'bossman^' for his AMSD tool which gives me the
  18.     inspiring idea for this importer.
  19.  
  20.   Known 'Bugs':
  21.    - Temporary file will not be deleted
  22.      - No offline support
  23.  
  24. *****/
  25.  
  26. OPTIONS RESULTS
  27.  
  28.     IF ~SHOW('P',MIAMI.1) THEN DO
  29.         ADDRESS COMMAND
  30.             'run <>nil: MIAMI:MIAMI'
  31.             'sys:rexxc/Waitforport MIAMI.1'
  32.     END
  33.  
  34.     ADDRESS MIAMI.1
  35.         ISONLINE
  36.             IF ~RC THEN DO
  37.                 ONLINE
  38.             END
  39.  
  40. PARSE ARG portname
  41.  
  42. ADDRESS VALUE portname
  43.  
  44. MUIM_Busy_Move      = '0x80020001'
  45. MUIA_Busy_Speed     = '0x80020049'
  46. MUIV_Busy_Speed_Off =  0
  47.  
  48. maxfound            = 400
  49.  
  50. /* Get search string from RecentScript string gadget */
  51. string ID STR_PATT
  52. pattern  = result
  53.  
  54. IF pattern = "" THEN DO
  55.   request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "You must enter a search string in RecentScript"
  56.   RETURN
  57. END
  58.  
  59. IF SHOWLIST(H,'TCP') THEN DO
  60.  
  61.   IF OPEN(writehandle, 'T:RS.temp', 'W') THEN DO
  62.  
  63.     window ID OSWIN TITLE '"AmiNet Online Search "' PORT portname
  64.       text ID OSTXT LABEL 'Connect to ftp.wustl.edu...'
  65.       object CLASS '"Busy.mcc"' ID OSBUSY
  66.     endwindow
  67.  
  68.     IF OPEN(tcphandle, 'TCP:ftp.wustl.edu/1848', 'W') THEN DO
  69.  
  70.       text ID OSTXT LABEL 'Search for "'pattern'"...'
  71.       object ID OSBUSY ATTRS MUIA_Busy_Speed MUIV_Busy_Speed_Off
  72.  
  73.       WRITECH(tcphandle, 'max 'maxfound' ; find 'pattern' ; quit' || '0a'x || '0d'x)
  74.  
  75.       text ID OSTXT LABEL 'Retrieve search result...'
  76.  
  77.       DO UNTIL EOF(tcphandle)
  78.  
  79.         method ID OSBUSY MUIM_Busy_Move
  80.  
  81.         line = READLN(tcphandle)
  82.  
  83.         IF LEFT(line,6)='*** No' then leave
  84.  
  85.         WRITELN(writehandle, line)
  86.       END
  87.  
  88.       CLOSE(tcphandle)
  89.       CLOSE(writehandle)
  90.       window ID OSWIN CLOSE
  91.  
  92.       RETURN "T:RS.temp"
  93.  
  94.     END
  95.     ELSE DO
  96.       request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "Cannot connect to 'ftp.wustl.edu'"
  97.     END
  98.  
  99.     window ID OSWIN CLOSE
  100.     CLOSE(writehandle)
  101.   END
  102.   ELSE DO
  103.     request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "Cannot open temporary file"
  104.   END
  105. END
  106. ELSE DO
  107.   request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "No TCP/IP found - You must be online!"
  108. END
  109.  
  110. RETURN